﻿<?php
require('../config.php');
require('tpl/auth/auth.php');
?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Admin</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.5 -->
    <link rel="stylesheet" href="../plugins/bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="../dist/css/font-awesome-4.5.0/css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="../plugins/ionicons-2.0.1/ionicons-2.0.1/css/ionicons.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="../dist/css/AdminLTE.min.css">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" href="../dist/css/skins/_all-skins.min.css">
    <!-- iCheck -->
    <link rel="stylesheet" href="../plugins/iCheck/flat/blue.css">
    <!-- Morris chart -->
    <link rel="stylesheet" href="../plugins/morris/morris.css">
    <!-- jvectormap -->
    <link rel="stylesheet" href="../plugins/jvectormap/jquery-jvectormap-1.2.2.css">
    <!-- Date Picker -->
    <link rel="stylesheet" href="../plugins/datepicker/datepicker3.css">
    <!-- Daterange picker -->
    <link rel="stylesheet" href="../plugins/bootstrap-daterangepicker-master/daterangepicker.css">
    <!-- bootstrap wysihtml5 - text editor -->
    <link rel="stylesheet" href="../plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
      <style>
          .wrapper{
              position: absolute;
              top: 0;
              width: 100%;
          }
          .date { position: relative;margin-bottom: 20px }
          .date i {
              position: absolute; bottom: 10px; right: 24px; top: auto; cursor: pointer;
          }
          .product-modal,.pipe-modal {
              position: absolute;
              margin: auto;
              top: 0;
              bottom: 0;
              display: block;
              z-index: 999;
              display: none;
          }
          .pipe-modal .modal{
              max-height: 500px;
              overflow-y: auto;
          }
          .product-modal .modal,.pipe-modal .modal {
              position: relative;
              top: 80px;
              bottom: auto;
              right: auto;
              left: auto;
              display: block;
              z-index: 1;
              background: transparent !important;
          }
          .product-modal .modal-body{
              text-align: center;
          }
          .pipe-modal .modal-body{
              text-align: left;
              margin-left: 15%;;
          }
          .product-modal-cover{
              position: absolute;
              width: 100%;
              height: 100%;
              z-index: 998;
              left: 0;
              top:0;
              background: rgba(0,0,0,0.2);
              display: none;
          }
          .ck-val{
              width:50px;
          }
          .typediff{
              display: none;
          }
      </style>
  </head>
  <body class="hold-transition skin-blue sidebar-mini">

  <div class="wrapper">

      <?php require('tpl/common/nav.html');?>
      <?php if($_GET['p']=='dashboard'){
          require('tpl/dashboard/dashboard.html');}?>
      <?php if($_GET['p']=='admin_user'){
          require('tpl/user/admin_user.html');}?>
      <?php if($_GET['p']=='pipe_user'){
          require('tpl/user/pipe_user.html');}?>
      <?php if($_GET['p']=='product_mani'){
          require('tpl/product/product_mani.html');}?>
      <?php if($_GET['p']=='data_mani'){
          require('tpl/data/data_mani.html');}?>
  </div>
  <!--  <script src="../plugins/requirejs/require.js" data-main="js/config.js"></script>-->
  <!-- jQuery 2.1.4 -->
  <script src="../plugins/jQuery/jQuery-2.1.4.min.js"></script>
  <!-- Bootstrap 3.3.5 -->
  <script src="../plugins/bootstrap/js/bootstrap.min.js"></script>
  <!-- Morris.js charts -->
  <script src="../plugins/morris/morris.min.js"></script>
  <!-- Sparkline -->
  <script src="../plugins/sparkline/jquery.sparkline.min.js"></script>
  <!-- DataTables -->
  <script src="../plugins/datatables/jquery.dataTables.min.js"></script>
  <script src="../plugins/datatables/dataTables.bootstrap.min.js"></script
      <!-- jQuery Knob Chart -->
  <script src="../plugins/knob/jquery.knob.js"></script>
  <!-- daterangepicker -->
  <script src="../plugins/bootstrap-daterangepicker-master/moment.js"></script>
  <script src="../plugins/bootstrap-daterangepicker-master/daterangepicker.js"></script>
  <!-- Bootstrap WYSIHTML5 -->
  <script src="../plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
  <!-- Slimscroll -->
  <script src="../plugins/slimScroll/jquery.slimscroll.min.js"></script>
  <!-- FastClick -->
  <script src="../plugins/fastclick/fastclick.min.js"></script>
  <!-- AdminLTE App -->
  <script src="../dist/js/app.min.js"></script>

  <script>
      $(function () {
          $('#data-tabel').DataTable({
              "paging": false,
              "lengthChange": false,
              "searching": false,
              "ordering": false,
              "info": false,
              "autoWidth": true
          });
          bindDateMani();
          getProductList();
          bindInit();
          bindDom();
          getDataList();
          getAdminList();
          getPipeList();
      });
      var startTime,endTime;
      var pipeName;
      var page=1;
      //初始化时间
      var date = new Date();
      var initTime = date.getFullYear()+'-'+(date.getMonth()+1)+'-'+(date.getDate()-1);
      function bindInit(){
          $('#add-product-btn').on('click',function(){
              modalShow();
          });
          $('#add-pipe-btn').on('click',function(){
              pipeModalShow();
          });
          $('#exportCSV').on('click',function(){
              exportCSV();
          });
          $('.pagination li:first').on('click',function(){
              pageMani(1,getPipeList);
          });
          $('.pagination li:last').on('click',function(){
              pageMani(0);
              getPipeList();
          });
          $('#data-search').on('change',function(){
              pipeName=$('#data-search').val();

              getDataList(startTime,endTime,pipeName);
          });

          $('.pipe-type').on('change',function(){
              var type = $('.pipe-type').val();
              $('.typediff').hide();
              if(type == 1){
                  $('.typediff:first').val('');
                  $('.typediff:last').fadeIn();
              }else if (type == 0){
                  $('.typediff:last').val('');
                  $('.typediff:first').fadeIn();

              }
          })
      }
      function bindDom(){
          $('.product-del').off('click').on('click',function(){
              var id = $(this).attr('title');
              deleteProduct(id);
          });
          $('.data-del').off('click').on('click',function(){
              var id = $(this).attr('title');
              deleteData(id);
          });
          $('.pipe-del').off('click').on('click',function(){
              var id = $(this).attr('title');
              deletePipe(id);
          });
          $('.pipe-edit-model-close').off('click').on('click',function(){
              $('.pipe-edit-model').fadeOut();
          });

      }
      function getAdminList(){
          $.ajax({
                  url: 'apis/user.php',
                  type: 'GET',
                  dataType: 'json',
                  data: {
                      type : 0,
                      page : 1,
                  }
              })
              .done(function(data) {
                  if(data==0){

                  }else{

//                      console.log(data);
                      $('#adminTable').empty();
                      for( i in data){
                          var string = "<tr><td>"+data[i].id+"</td>"+
                              "<td>"+data[i].username+"</td>"+
                              "<td>"+data[i].password+"</td>"+
                              "<td>"+data[i].login_time+"</td>"+
                              "<td><a href='#'><i class='fa fa-edit'></i></a>&nbsp&nbsp&nbsp<a href='#'>"+
                              "<i class='fa fa-times product-del' title='"+data[i].id+"'></i></a></td></tr>";
                          $('#adminTable').append(string);
                      }
                      bindDom();
                  }

              })
              .fail(function() {
                  console.log("error");
              })
              .always(function() {
                  console.log("complete");
              });
      }
      function getPipeList(){
          $.ajax({
                  url: 'apis/user_pipe.php',
                  type: 'GET',
                  dataType: 'json',
                  data: {
                      type : 1,
                      page : page,
                  }
              })
              .done(function(data) {
                  if(data==0){

                  }else{

//                      console.log(data);
                      $('#pipeTable').empty();
                      for( i in data){
                          var string = "<tr>"+
                              "<td>"+data[i].pipe_name+"</td>"+
                              "<td>"+(data[i].pipe_type==0?'cpa':'cps')+"</td>"+
                              "<td>"+data[i].unit_price+"</td>"+
                              "<td>"+(data[i].pipe_type==0?"周期："+data[i].clear_cycle:"比例："+data[i].clear_cycle)+"</td>"+
                              "<td>"+data[i].product_name+"</td>"+
                              "<td>"+data[i].pipe_username+"</td>"+
                              "<td>"+data[i].pipe_pass+"</td>"+
                              "<td>"+data[i].company_name+"</td>"+
                              "<td>"+data[i].company_address+"</td>"+
                              "<td>"+data[i].contact_name+"</td>"+
                              "<td>"+data[i].contact_tel+"</td>"+
                              "<td><a href='#'><i class='fa fa-edit pipe-edit' title='"+data[i].id+"'></i></a>&nbsp&nbsp|&nbsp&nbsp<a href='#'>"+
                              "<i class='fa fa-times pipe-del' title='"+data[i].id+"'></i></a></td></tr>";
                          $('#pipeTable').append(string);
                      }
                      bindDom();
                      $('.pipe-edit').off('click').on('click',function(){
                          $('.pipe-edit-model').fadeIn();
                          var id = $(this).attr('title');
                          centerPipeDetails(id);
                      });
                  }

              })
              .fail(function() {
                  console.log("error");
              })
              .always(function() {
                  console.log("complete");
              });
      }
      function centerPipeDetails(id) {
          $.ajax({
              type: 'GET',
              url: "apis/pipe.php",
              data: {
                  'id': id
              },
              dataType: 'json',
              success: function (data) {
                  console.log(data);
                  $('#update_pipe_name').val(data.pipe_name);
                  $('#update_pipe_type').val(data.pipe_type==0?'cpa':'cps');
                  $('#update_unit_price').val(data.unit_price);
                  $('#update_clear_cycle').val(data.clear_cycle);
                  $('#update_product_name').val(data.product_name);
                  $('#update_pipe_username').val(data.pipe_username);
                  $('#update_pipe_pass').val(data.pipe_pass);
                  updatePipeDetails(data.id);
              }
          });
      }
      function updatePipeDetails(id) {

          $('.update-pipe').off('click').on('click', function () {
              var pipe_name = $('#update_pipe_name').val(),
                  pipe_type = $('#update_pipe_type').val(),
                  unit_price = $('#update_unit_price').val(),
                  clear_cycle = $('#update_clear_cycle').val(),
                  product_name = $('#update_product_name').val(),
                  pipe_username = $('#update_pipe_username').val(),
                  pipe_pass = $('#update_pipe_pass').val();

              $.ajax({
                  type: 'GET',
                  url: "apis/pipe.php?action=update",
                  data: {
                      'id': id,
                      'pipe_name': pipe_name,
                      'pipe_type': pipe_type,
                      'unit_price': unit_price,
                      'clear_cycle': clear_cycle,
                      'product_name': product_name,
                      'pipe_username': pipe_username,
                      'pipe_pass': pipe_pass
                  },
                  dataType: 'json',
                  success: function (data) {
                      if (data == 1) {
                          alert('修改成功');
                          $('.pipe-edit-model').fadeOut();
                          getPipeList();

                      } else {
                          alert('更新失败');
                      }
                  },
                  error: function (data) {
                      console.log("error");
                      console.log(data);
                  },
                  always: function () {

                  }
              });
          });
      }
      function bindDateMani(){
          $('#data-dp').daterangepicker({
              startDate:initTime,
              endDate:initTime,
              locale: {
                  format: 'YYYY-MM-DD'
              },
          }, function(start, end) {

              startTime = start.format('YYYY-MM-DD');
              endTime = end.format('YYYY-MM-DD');
              getDataList(startTime, endTime, pipeName);

          });
      }


      function getDataList(startTime,endTime,pipeName){
          $.ajax({
                  url: 'apis/data_date_select.php',
                  type: 'GET',
                  dataType: 'json',
                  data: {
                      'startTime' : startTime?startTime:initTime,
                      'endTime' : endTime?endTime:initTime,
                      'pipeName' : pipeName?pipeName:'',
                  },
              })
              .done(function(data) {
                  console.log(data);
                  $('#dateTable').empty();

                  for(var i in data ){
                      var string = "<tr>"+
                          "<td>"+data[i].time+"</td>"+
                          "<td>"+data[i].product_name+"</td>"+
                          "<td>"+data[i].pipe_name+"</td>"+
                          "<td>"+data[i].new_user_number+"</td>"+
                          "<td>"+data[i].sf_new_user_number+"</td>"+
                          "<td>"+data[i].active_user+"</td>"+
                          "<td class='pipe-type' title='"+data[i].pipe_type+"'>"+(data[i].pipe_type==0?(data[i].active_user_ck!=-1?data[i].active_user_ck:"<input type='text' title='"+data[i].id+"' class='ck-val'>"):"不需要")+"</td>"+
                          "<td>"+(data[i].pipe_type==0?'<span style="color:red">cpa</span>':'<span style="color:blue">cps</span>')+"</td>"+
                          "<td class='money-rate'>"+data[i].money_rate+"</td>"+
                          "<td class='money-all-info'>"+data[i].money_all_info+"</td>"+
                          "<td>"+data[i].display_rate+"</td>"+
                          "<td>"+data[i].money_display+"</td>"+
                          "<td class='benefit'>"+data[i].benefit+"</td>"+
                          "<td class='benefit-rate'>"+data[i].benefit_rate+"</td>"+
                          "<td>"+data[i].submit_date+"</td>"+
                          "<td>"+(data[i].status==0?'<a title="'+data[i].id+'" class="btn btn-danger changeStatusBtn">未审核</a>':'<a title="'+data[i].id+'" class="btn btn-primary changeStatusBtn">已审核</a>')+"<a href='#'><i class='fa fa-times data-del' title='"+data[i].id+"'></i></a></td>"+
                          "<tr>";
                      $('#dateTable').append(string);
                  }

                  $('.ck-val').on('change',function(){

                      var moneyAllInfo = $(this).parents('tr').find('.money-all-info').text();
                      var moneyRate = $(this).parents('tr').find('.money-rate').text();
                      var pipeType = $(this).parents('tr').find('.pipe-type').attr('title');
                      var ckVal = $(this).val();
                      var benefit = moneyAllInfo*0.4-ckVal*moneyRate;
                      var benefitRate = benefit/moneyAllInfo;
                      benefit=benefit.toFixed(2);
                      benefitRate=benefitRate.toFixed(2);
                      var id = $(this).attr('title');

                      $(this).parents('tr').find('.benefit').html(benefit);
                      $(this).parents('tr').find('.benefit-rate').html(benefitRate);

                      $(this).parents('tr').find('.changeStatusBtn').off('click').on('click' , function(){
                          var id = $(this).attr('title');
                          changeStatus(id,ckVal,pipeType,benefit,benefitRate);

                      })
                  });
                  bindTimeRangePickerDom();
              })
              .fail(function() {
                  console.log("error");
              })
              .always(function() {
                  console.log("complete");
              });
      }
      function bindTimeRangePickerDom() {
          $('.changeStatusBtn').off('click').on('click', function () {
              var moneyAllInfo = $(this).parents('tr').find('.money-all-info').text();
              var moneyRate = $(this).parents('tr').find('.money-rate').text();
              var pipeType = $(this).parents('tr').find('.pipe-type').attr('title');
              var ckVal = $(this).val();
              var benefit = moneyAllInfo*0.4-ckVal*moneyRate;
              var benefitRate = benefit/moneyAllInfo;
              var id = $(this).attr('title');
              changeStatus(id,ckVal,pipeType,benefit,benefitRate);
          })
      }
      function changeStatus(id,ckVal,pipeType,benefit,benefitRate){
          $.ajax({
                  url: 'apis/data_status.php',
                  type: 'GET',
                  dataType: 'json',
                  data: {
                      'id' : id,
                      'ckVal' : ckVal>=0?ckVal:null,
                      'pipeType' : pipeType>=0?pipeType:null,
                      'benefit' : benefit>=0?benefit:null,
                      'benefitRate' : benefitRate>=0?benefitRate:null
                  }
              })
              .done(function(data) {
                  getDataList(startTime,endTime,pipeName);

              })
              .fail(function() {
                  console.log("error");
              })
              .always(function() {
                  console.log("complete");
              });
      }
      function bindProductMani(){
          $('#product-dp').daterangepicker({
//          "startDate": "2016-04-21",
//          "endDate": "2016-04-22",
              locale: {
                  format: 'YYYY-MM-DD'
              },
          }, function(start, end) {
              var startTime = start.format('YYYY-MM-DD');
              var endTime = end.format('YYYY-MM-DD');
              $.ajax({
                      url: 'apis/data_date_select.php',
                      type: 'GET',
                      dataType: 'json',
                      data: {
                          'startTime' : startTime,
                          'endTime' : endTime
                      },
                  })
                  .done(function(data) {
                      $('#dateTable').empty();
                      for( i in data ){
                          var string = "<tr>"+
                              "<td>"+data[i].time+"</td>"+
                              "<td>"+data[i].product_name+"</td>"+
                              "<td>"+data[i].pipe_name+"</td>"+
                              "<td>"+data[i].new_user_number+"</td>"+
                              "<tr>";
                          console.log(string);
                          $('#dateTable').append(string);
                      };
                  })
                  .fail(function() {
                      console.log("error");
                  })
                  .always(function() {
                      console.log("complete");
                  });
          });
      }
      function modalShow(){

          $('.product-modal-cover').fadeIn(300);
          $('.product-modal').fadeIn(300);
          $('.product-modal button:eq(1)').off('click').on('click',function(){
              modalHide();
          });
          $('.product-modal button:eq(0)').off('click').on('click',function(){
              modalHide();
          });
          $('.product-modal button:eq(2)').off('click').on('click',function(){
              var productName = $('.product-name');
              var productType = $('.product-type');
              var name = productName.val();
              var type = productType.val();

              addNewProduct(name,type);
              productName.val('');
              productType.val('');
              modalHide();
          });
//            $('.product-modal button').fadeIn(300);

      }
      function pipeModalShow(){
          $('.product-modal-cover').fadeIn(300);
          $('.pipe-modal').fadeIn(300);
          $('.pipe-modal button:eq(1)').off('click').on('click',function(){
              modalHide();
          });
          $('.pipe-modal button:eq(0)').off('click').on('click',function(){
              modalHide();
          });

          $('.pipe-modal button:eq(2)').off('click').on('click',function(){
              var clearCycle;

              var pipeName = $('.pipe-name').val();
              var pipeType = $('.pipe-type').val();
              var unitPrice = $('.unit-price').val();
              var productName= $('.product-name').val();
              var pipeUsername = $('.pipe-username').val();
              var pipePass = $('.pipe-pass').val();
              var companyName = $('.company-name').val();
              var companyAddress = $('.company-address').val();
              var contactName = $('.contact-name').val();
              var contactTel = $('.contact-tel').val();
              if(pipeType==0){
                  clearCycle = $('.clear-cycle:first').val();
              }else if(pipeType==1){
                  clearCycle = $('.clear-cycle:last').val();
              }

              console.log(pipeType,clearCycle,productName);
              addNewPipe(pipeName,pipeType,unitPrice,clearCycle,productName,pipeUsername,pipePass,companyName,companyAddress,contactName,contactTel);
              modalHide();
              clearPipeInfo();
          });
      }
      function clearPipeInfo(){


          $('.pipe-name').val('');
          $('.pipe-type').val('');
          $('.unit-price').val('');
          $('.product-name').val('');
          $('.pipe-username').val('');
          $('.pipe-pass').val('');
          $('.company-name').val('');
          $('.company-address').val('');
          $('.contact-name').val('');
          $('.contact-tel').val('');

          $('.clear-cycle:first').val();

          $('.clear-cycle:last').val();

      }
      function addNewPipe(pipeName,pipeType,unitPrice,clearCycle,productName,pipeUsername,pipePass,companyName,companyAddress,contactName,contactTel){
          $.ajax({
                  url: 'apis/user_pipe.php?action=add',
                  type: 'GET',
                  dataType: 'json',
                  data: {
                      'pipeName' : pipeName,
                      'pipeType' : pipeType,
                      'unitPrice' : unitPrice,
                      'clearCycle' : clearCycle,
                      'productName' : productName,
                      'pipeUsername' : pipeUsername,
                      'pipePass' : pipePass,
                      'companyName' : companyName,
                      'companyAddress' : companyAddress,
                      'contactName' : contactName,
                      'contactTel' : contactTel
                  },
              })
              .done(function(data) {
                  if(data>0){
//                        alert('插入成功');
                      getPipeList();

                  }else{
                      alert('缺失参数');
                  }
              })
              .fail(function() {
                  console.log("error");
              })
              .always(function() {
                  console.log("complete");
              });
      }
      function modalHide() {
          $('.product-modal-cover').fadeOut(0);
          $('.product-modal').fadeOut(300);
          $('.pipe-modal').fadeOut(300);
      }
      function getProductList(){
          $.ajax({
                  url: 'apis/product_list.php',
                  type: 'GET',
                  dataType: 'json',
              })
              .done(function(data) {
                  $('#productTable').empty();
                  for( i in data){
                      var string = "<tr><td>"+data[i].id+"</td>"+
                          "<td>"+data[i].name+"</td>"+
                          "<td>"+data[i].type+"</td>"+
                          "<td>"+data[i].time+"</td>"+
                          "<td><a href='#'><i class='fa fa-edit'></i></a>&nbsp&nbsp&nbsp<a href='#'>"+
                          "<i class='fa fa-times product-del' title='"+data[i].id+"'></i></a></td></tr>";
                      $('#productTable').append(string);
                  }
                  bindDom();
              })
              .fail(function() {
                  console.log("error");
              })
              .always(function() {
                  console.log("complete");
              });
      }
      function addNewProduct(name,type){
          $.ajax({
                  url: 'apis/product_add.php',
                  type: 'GET',
                  dataType: 'json',
                  data: {

                      'name' : name,
                      'type' : type,
                  },
              })
              .done(function(data) {
                  if(data>0){
//                        alert('插入成功');
                      getProductList();

                  }else{
                      alert('缺失参数');
                  }
              })
              .fail(function() {
                  console.log("error");
              })
              .always(function() {
                  console.log("complete");
              });
      }
      function deleteProduct(id){
          var result = confirm('确认删除当前产品吗？');
          if(result==true){
              $.ajax({
                      url: 'apis/product_del.php',
                      type: 'GET',
                      dataType: 'json',
                      data: {

                          'id' : id,
                      },
                  })
                  .done(function(data) {
                      if(data==1){
                          alert('删除成功');
                          getProductList();
                      }else{
                          alert('缺失参数');
                      }
                  })
                  .fail(function() {
                      console.log("error");
                  })
                  .always(function() {
                      console.log("complete");
                  });
          }
      }
      function deleteData(id){
          var result = confirm('确认删除当前产品吗？');
          if(result==true){
              $.ajax({
                      url: 'apis/data_del.php',
                      type: 'GET',
                      dataType: 'json',
                      data: {

                          'id' : id,
                      },
                  })
                  .done(function(data) {
                      if(data==1){
                          alert('删除成功');
                          getDataList(startTime, endTime, pipeName);
                      }else{
                          alert('缺失参数');
                      }
                  })
                  .fail(function() {
                      console.log("error");
                  })
                  .always(function() {
                      console.log("complete");
                  });
          }
      }
      function deletePipe(id){
          var result = confirm('确认删除当前渠道吗？');
          if(result==true){
              $.ajax({
                      url: 'apis/user_pipe.php?action=del',
                      type: 'GET',
                      dataType: 'json',
                      data: {
                          'id' : id,
                      },
                  })
                  .done(function(data) {
                      if(data==1){
                          alert('删除成功');
                          getPipeList();
                      }else{
                          alert('缺失参数');
                      }
                  })
                  .fail(function() {
                      console.log("error");
                  })
                  .always(function() {
                      console.log("complete");
                  });
          }
      }
      function editProduct(){

      }
      function exportCSV(){
          $.ajax({
                  url: 'apis/data_excel.php',
                  type: 'GET',
                  dataType: 'json',
                  data: {
                      'action' : 'export',
                      'startTime' : startTime?startTime:'',
                      'endTime' : endTime?endTime:''
                  },
              })
              .done(function(data) {
                  alert('请稍等');
              })
              .fail(function() {
                  console.log("error");
              })
              .always(function() {
                  console.log("complete");
              });
      }
      function pageMani(action, callback){
          if(action==0){
              page++;
          } else if (action==1){
              if(page=1){
                  $('.pagination').find('li:first').addClass('disabled');
              }else if(page>1){
                  page--;
                  if(callback){
                      callback();
                  }
              }
          } else if (action=='reset'){
              page=1;
          }
      }
  </script>
  </body>
  <script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1257484594'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s11.cnzz.com/z_stat.php%3Fid%3D1257484594' type='text/javascript'%3E%3C/script%3E"));</script>
</html>
